package com.ruoyi.system.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.AppUserEquipmentMapper;
import com.ruoyi.system.domain.AppUserEquipment;
import com.ruoyi.system.service.IAppUserEquipmentService;

/**
 * 用户设备Service业务层处理
 *
 * @author ruoyi
 * @date 2023-02-27
 */
@Service
public class AppUserEquipmentServiceImpl implements IAppUserEquipmentService {
    @Autowired
    private AppUserEquipmentMapper appUserEquipmentMapper;

    /**
     * 查询用户设备
     *
     * @param id 用户设备主键
     * @return 用户设备
     */
    @Override
    public AppUserEquipment selectAppUserEquipmentById(Long id) {
        return appUserEquipmentMapper.selectAppUserEquipmentById(id);
    }

    /**
     * 查询用户设备列表
     *
     * @param appUserEquipment 用户设备
     * @return 用户设备
     */
    @Override
    public List<AppUserEquipment> selectAppUserEquipmentList(AppUserEquipment appUserEquipment) {
        return appUserEquipmentMapper.selectAppUserEquipmentList(appUserEquipment);
    }

    /**
     * 新增用户设备
     *
     * @param appUserEquipment 用户设备
     * @return 结果
     */
    @Override
    public int insertAppUserEquipment(AppUserEquipment appUserEquipment) {
        return appUserEquipmentMapper.insertAppUserEquipment(appUserEquipment);
    }

    /**
     * 修改用户设备
     *
     * @param appUserEquipment 用户设备
     * @return 结果
     */
    @Override
    public int updateAppUserEquipment(AppUserEquipment appUserEquipment) {
        return appUserEquipmentMapper.updateAppUserEquipment(appUserEquipment);
    }

    /**
     * 批量删除用户设备
     *
     * @param ids 需要删除的用户设备主键
     * @return 结果
     */
    @Override
    public int deleteAppUserEquipmentByIds(Long[] ids) {
        return appUserEquipmentMapper.deleteAppUserEquipmentByIds(ids);
    }

    /**
     * 删除用户设备信息
     *
     * @param id 用户设备主键
     * @return 结果
     */
    @Override
    public int deleteAppUserEquipmentById(Long id) {
        return appUserEquipmentMapper.deleteAppUserEquipmentById(id);
    }

    @Override
    public AppUserEquipment getOne(AppUserEquipment equipment) {
        List<AppUserEquipment> list = appUserEquipmentMapper.selectAppUserEquipmentList(equipment);
        return list.size() > 0 ? list.get(0) : null;
    }

    @Override
    public void save(AppUserEquipment userEquipment) {
        appUserEquipmentMapper.insertAppUserEquipment(userEquipment);
    }

    @Override
    public void updateById(AppUserEquipment userEquipment) {
        appUserEquipmentMapper.updateAppUserEquipment(userEquipment);
    }

    @Override
    public AppUserEquipment getOneByEquipmentId(String equipmentId) {
        return appUserEquipmentMapper.getOneByEquipmentId(equipmentId);
    }

    @Override
    public AppUserEquipment getOneByUserId(Long userId) {
        AppUserEquipment info = new AppUserEquipment();
        info.setUserId(userId);
        List<AppUserEquipment> list = appUserEquipmentMapper.selectAppUserEquipmentList(info);
        return list.size() > 0 ? list.get(0) : null;
    }
}
